﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using FC.Model;


namespace FC.ViewModel.IterationVMs
{
    public partial class IterationListVM : BasePagedListVM<Iteration_View, IterationSearcher>
    {

        protected override IEnumerable<IGridColumn<Iteration_View>> InitGridHeader()
        {
            return new List<GridColumn<Iteration_View>>{
                this.MakeGridHeader(x => x.Name_view),
                this.MakeGridHeader(x => x.Name),
                this.MakeGridHeader(x => x.StartTime),
                this.MakeGridHeader(x => x.EndTime),
                this.MakeGridHeaderAction(width: 200)
            };
        }

        public override IOrderedQueryable<Iteration_View> GetSearchQuery()
        {
            var query = DC.Set<Iteration>()
                .Select(x => new Iteration_View
                {
				    ID = x.ID,
                    Name_view = x.ChargeUser.Name,
                    Name = x.Name,
                    StartTime = x.StartTime,
                    EndTime = x.EndTime,
                })
                .OrderBy(x => x.ID);
            return query;
        }

    }

    public class Iteration_View : Iteration{
        [Display(Name = "_Admin.Name")]
        public String Name_view { get; set; }

    }
}
